package com.lfx.half;

/**
 * @author 李逢喜
 * create 2021/7/15
 */
public class HalfDemo2 {


    public static int search(int[]nums ,int start, int end,int n){

        if(start>end) return -1;

        int mid=(start+end)/2;
        if(nums[mid]>n){
            end=end-1;
        }else  if(nums[mid]<n){
            start=start+1;
        }else
            return nums[mid];

        return search(nums,start,end,n);
    }


    public static void main(String[] args) {
        int[] nums={12,45,66,77,99,104,200,500};
        System.out.println(search(nums,0,nums.length,500 ));
    }
}
